package com.nsfocus.network;

import javax.activation.DataSource;
import java.io.*;
import java.net.Socket;

/**
 * @File: Client.java
 * @User: Liangkangkang
 * @Date: 17-4-24
 * @Time: 下午1:11
 * @Mail: liangkangkang@yahoo.com
 * @Desc:
 * @Version:
 */

public class Client {
    public static void main(String[] args) {
        String lineEnd = "\n";
        try {
            Socket s = new Socket("localhost",8888);
            // input stream
            InputStream is = s.getInputStream();
            // output stream
            OutputStream os = s.getOutputStream();

            // read
            BufferedReader br = new BufferedReader(new InputStreamReader(is,"gbk"));

            // write
            BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os,"gbk"));

            bw.write("abc!!!" + lineEnd);
            bw.flush();
            System.out.println(br.readLine());
            br.close();
            bw.close();

//            System.out.println("client");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
